package cn.edu.lingnan.springbootlingnanblog.service.impl;

import cn.edu.lingnan.springbootlingnanblog.entity.Blogger;
import cn.edu.lingnan.springbootlingnanblog.dao.BloggerDao;
import cn.edu.lingnan.springbootlingnanblog.service.BloggerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TBlogger)表服务实现类
 *
 * @author makejava
 * @since 2020-06-13 08:34:07
 */
@Service("BloggerService")
public class BloggerServiceImpl implements BloggerService {
    @Resource
    private BloggerDao BloggerDao;

    @Override
    public Blogger getByName(String name) {
        return BloggerDao.getByName(name);
    }

    @Override
    public Blogger login(String name, String password) {
        return BloggerDao.login(name, password);
    }


    @Override
    public Blogger queryById(Integer id) {
        return this.BloggerDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Blogger> queryAllByLimit(int offset, int limit) {
        return this.BloggerDao.queryAllByLimit(offset, limit);
    }


    @Override
    public boolean insert(Blogger tBlogger) {
        return this.BloggerDao.insert(tBlogger) > 0 ;
    }


    @Override
    public boolean update(Blogger tBlogger) {

        return this.BloggerDao.update(tBlogger) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功b
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.BloggerDao.deleteById(id) > 0;
    }
}